home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr48
/
pas_0593.zip
/
EXTEND.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
3KB
|
124 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 510 of 527
From : Mark Lewis 1:3634/12.0 17 May 93 02:25
To : BRIAN PAPE
Subj : File overflow
────────────────────────────────────────────────────────────────────────────────
> HB>Your cup runnith over?... Not quite sure what you mean by file
> HB>overflow, but it sounds like you need to increase the FILES=
> HB>in your config.sys.
> The problem is that without allocating a new FCB for DOS, you
> can't have more than 15 or so files open at a time in TP, no
> matter WHAT the CONFIG.SYS FILES= statement says. (By default,
i cannot remember exactly what INT $21 function $6700 is but here's a PD unit i
got from borland's bbs the other day... i've trimmed the text down for
posting... if anyone really needs everything that comes with it, they should
look for EXTEND6.*}
unit Extend;
{This extends the number of FILE handles from 20 to 255}
{DOS requires 5 for itself. Applications can use up to 250}
interface
implementation
uses dos;
const
Handles =255;
{You can reduce the value passed to Handles if fewer files}
{are required.}
var
reg:registers;
begin
{Check the Dos Version}
{This technique only works for DOS 3.0 or later}
reg.ah:=$30;
MsDos(reg);
if reg.al<3 then
begin
writeln('Extend Unit Require DOS 3.0 or greater');
halt(1);
end;
{Reset the FreePtr}
{This reduces the heap space used by Turbo Pascal}
if HeapOrg<>HeapPtr then
{Checks to see if the Heap is empty}
begin
write('Heap must be empty before Extend unit initializes');
writeln;
halt(1);
end;
HeapEnd:=ptr(Seg(HeapEnd^)-(Handles div 8 +1), Ofs(HeapEnd^));
{Determine how much memory is allocated to program}
{Reg.Bx will return how many paragraphs used by program}
reg.ah:=$4A;
reg.es:=PrefixSeg;
reg.bx:=$FFFF;
msdos(reg);
{Set the program size to the allow for new handles}
reg.ah:=$4A;
reg.es:=PrefixSeg;
reg.bx:=reg.bx-(Handles div 8 +1);
msdos(reg);
{Error when a Block Size is not appropriate}
if (reg.flags and 1)=1 then
begin
Writeln('Runtime Error ',reg.ax,' in Extend.');
halt(1);
end;
{Allocate Space for Additional Handles}
reg.ah:=$67;
reg.bx:=Handles;
MsDos(reg);
end.
Write the following program to a separate FILE. This program
tests the EXTEND unit. This test should be done on systems
equipped with a hard disk.
program TestEx;
uses EXTEND;
type
filearray=array[1..250] of text;
var
f:^filearray;
i:integer;
s:string;
begin
{Allocate Space for fILE Variable Table}
new(f);
{oPEN 250 files simultaneously}
for i:=1 to 250 do
begin
str(i,s);
Assign(f^[i],'Dum'+s+'.txt');
rewrite(f^[i]);
writeln('Open #',s);
end;
{Write some text to the files}
for i:=1 to 250 do
write(f^[i],'This is a test file');
{Close the files}
for i:=1 to 250 do
begin
close(f^[i]);
writeln('Closing #',i);
end;
{Erase the files}
for i:=1 to 250 do
begin
erase(f^[i]);
writeln('Erasing #',i);
end;
end.